﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using EasyMvcBlog.DTO;
using EasyMvcBlog.Data;
using EasyMvcBlog.Infrastructure.Repository.DataRepository;

namespace EasyMvcBlog.Domain
{
    public class MenuDomain 
    {
        MenuRepository menuRepository = new MenuRepository();

        /// <summary>
        /// 获得排序后的菜单列表
        /// </summary>
        /// <returns></returns>
        public IList<MenuDTO> GetOrderedMenu()
        {
            List<Menu> menus = menuRepository.GetList(m => m.Id > 0).OrderBy(m => m.Priority).ToList();
            
            Mapper.CreateMap<Menu, MenuDTO>();
            return Mapper.Map<List<Menu>, List<MenuDTO>>(menus);
        }
    }
}
